void function () {
    //窗口隐藏检查
    window.music=window.music||{};
    if(window.music.isShowing===true){
        window.music.win.css("transform","rotateX(0deg)").mst("z100");
        setTimeout(function () {
            window.music.win.mst("tr0")
        },300);
        return;
    }
    //窗口显示注册
    window.music={isShowing:true};
    var media={
        loopType:0,
        id:0,
        playing:false,
        tag:$("<audio></audio>")[0],
        id_list:[7316465,18627254,18905853,238700422,790142,276766,124287768,31305048,100036643,276867440,541983908,547230801,566044370],
        fn:{
            loopType:
                [
                    //列表循环
                    function () {
                        //获取下一曲id
                        media.id<media.id_list.length-1?
                            media.id++:
                            media.id=0;
                        media.tag.updateSong(media.id_list[media.id]);
                        //播放
                    },

                    //单曲循环
                    function () {
                        //暂停

                        //播放


                    },
                    //随机播放
                    function () {
                        //暂停

                        //随机获取下一曲id
                        var id=Math.floor(Math.random()*(media.id_list.length-1));
                        media.tag.updateSong(id);
                        //播放

                    }
                ]
        }
    };
    //初始化循环类型,状态恢复，数据恢复
    (function () {
        //音量恢复
        if(lsg("volume")!==null){
            media.tag.volume=lsg("volume");
        }
        //初始化循环类型
        var typeNum=media.fn.loopType.length;
        //只能有规定的循环类型
        if(media.loopType<0||media.loopType>=typeNum||isNaN(media.loopType)){
            media.loopType=0;
        }
        //调用循环方法
        $(media.tag).bind("ended",function () {
            media.fn.loopType[media.loopType]();
        });
    })();
    var st = {
        head:{
            change:null,
            search:null,
            close: null,
            min:null,
            theme:null
        },
        cont: {
            play: tag.div(),
            view: tag.div()
        },
        ctrl:{
            play:null
        }
    };
    var bg = {
        win: "#fff",
        head: "#313131",
        head_btn:"#ffffff",
        head_btn_md:"#999",
        cont: "none",
        ctrl: "#313131",
        text_color:"#fff"
    };
    var win = new Win();
    window.music.win=win;
    //核心框架
    var head = tag.div().attr("class", "asWindow").mst("h50;bg"+bg.head),
        cont = tag.div().mst("por;h550;ofh;bg" + bg.cont),
        ctrl = tag.div().mst("c#fff;h50;bg" + bg.ctrl);
    //顶部元素
    win.append(head, cont, ctrl).mst("bg" + bg.win);
    //初始化顶部 head
    void function () {
        var
            common = "fl;h30;mt10;ml10;",
            icon = tag.span().mst(common + "w30;bgs100% 100%;bdr30;cup;bd1px #fff solid;bgiurl('images/music/user/0.jpg')"),
            name = tag.span().mst(common + "w160;ofh;lh30;cup;c"+bg.text_color).html("SPB MUSIC"),
            change = tag.span().css("letter-spacing", "1px")
                .mst(common + "w120;tr300;bgcrgba(0,0,0,0.3);bgiurl('images/music/change.png');bgrn;bgp60px 0"),
            search = tag.span().mst(common + "w300;bgcrgba(255,255,255,0.1);por"),
            close = tag.canvas().mst("fr;h30;w30;mt10;mr10;bgrn;bgpcenter;cup").attr("title", "关闭"),
            min = tag.canvas().mst("fr;h30;w30;mt10;mr6;cup").attr("title", "最小化"),
            theme = tag.canvas().mst("fr;h30;w30;mt10;mr6;cup").attr("title", "主题");
            var home = tag.canvas().mst("fr;h30;w30;mt10;mr6;cup").attr("title", "主页");
        head.append(icon, name, change, search, close, min, theme,home);

            st.head.change=change;
            st.head.search=search;
            st.head.close=close;
            st.head.min=min;
            st.head.theme=theme;
            st.head.home=home;

        //init change
        (function () {
            var style = "w59;h28;tac;lh28;tr300;cup;ofh;";
            var bf = "1px solid rgba(255,255,255)";
            var b0 = "1px solid rgba(0,0,0,0)";
            var c_f = bg.head;
            var c_b = bg.text_color;
            var tag1_blur =
                {
                    "border-left": bf,
                    "border-top": bf,
                    "border-bottom": bf,
                    "color": c_b
                };
            var tag1_focus =
                {
                    "border-left": b0,
                    "border-top": b0,
                    "border-bottom": b0,
                    "color": c_f
                };
            var tag2_blur =
                {
                    "border-right": bf,
                    "border-top": bf,
                    "border-bottom": bf,
                    "color": c_b
                };
            var tag2_focus =
                {
                    "border-right": b0,
                    "border-top": b0,
                    "border-bottom": b0,
                    "color": c_f
                };
            function toPlay() {
                tag1.css(tag1_focus);
                tag2.css(tag2_blur);
                st.cont.play.mst("l0");
                st.cont.view.mst("l100%");
                st.head.change.mst("bgp0 0");
            }
            window.headChangeToPlay=toPlay;
            function toLib() {
                tag2.css(tag2_focus);
                tag1.css(tag1_blur);
                st.cont.play.mst("l-100%");
                st.cont.view.mst("l0");
                st.head.change.mst("bgp60px 0");
            }
            window.headChangeToLib=toLib;
            var tag1 = tag.span().mst(style + "c#fff;poa;l0").css(tag1_blur).html("播放").click(toPlay);

            var tag2 = tag.span().mst(style + "c#000;poa;r0").css(tag2_focus).html("曲库").click(toLib);


            st.head.change.append(tag.div().mst("por;w100%;h100%").append(tag1,tag2));
        })();
        //init search
        (function () {
            var tag1 = tag.input("input", "").mst("poa;l0;t0;m0;fz16;c#fff;bdnone;h30;w260;bgnone;pl10").css({"outline": "none"})
                .attr("placeholder", "搜索");
            var tag2 = tag.canvas().mst("poa;r0;t0;w40;h30;cup").attr("title", "搜索");
            st.head.search.append(tag1, tag2);
            st.head.searchIpt=tag1;
            st.head.searchBtn=tag2;
            var c = tag2[0];
            var o = c.getContext("2d");
            c.width = 40;
            c.height = 30;
            o.lineWidth = 2;
            var s = bg.head_btn;
            fun1();

            function fun1() {
                o.clearRect(0, 0, 40, 30);
                o.beginPath();
                o.strokeStyle = s;
                o.arc(19, 14, 8, 0, Math.PI * 2);
                o.closePath();
                o.stroke();
                o.beginPath();
                o.moveTo(25, 20);
                o.lineTo(30, 25);
                o.stroke();
            }

            tag2.bind({
                "mousedown": function () {
                    s = bg.head_btn_md;
                    fun1();
                },
                "mouseup mouseout": function () {
                    s = bg.head_btn;
                    fun1()
                }
            });


        })();
        //init close
        (function () {
            var c = st.head.close[0];
            var o = c.getContext("2d");
            c.width = 30;
            c.height = 30;
            o.lineWidth = 1;
            var s = bg.head_btn;
            fun1();

            function fun1() {
                o.clearRect(0, 0, 30, 30);
                o.strokeStyle = s;
                o.beginPath();
                o.moveTo(10, 10);
                o.lineTo(22, 22);
                o.stroke();
                o.beginPath();
                o.moveTo(10, 22);
                o.lineTo(22, 10);
                o.stroke();
            }

            st.head.close.bind({
                "mousedown": function () {
                    s = bg.head_btn_md;
                    fun1();
                },
                "mouseup mouseout": function () {
                    s = bg.head_btn;
                    fun1();
                },
                "click":function () {
                    _.body.removeChild(win[0]);
                    media.tag.pause();
                    media=null;
                    window.music=null;
                }
            });
        })();
        //init min
        (function () {
            st.head.min.click(function(){
                win.css({
                    "transition":"300ms",
                    "transform":"rotateX(90deg)"
                });
            });
            var c = st.head.min[0];
            var o = c.getContext("2d");
            c.width = 30;
            c.height = 30;
            var s1 = bg.head_btn, s2 = bg.head_btn_md;
            var s = s1;
            fun1();

            function fun1() {
                o.clearRect(0, 0, 30, 30);
                o.beginPath();
                o.fillStyle = s;
                o.fillRect(8, 18, 14, 1);
            }

            st.head.min.bind
            ({
                "mousedown": function () {
                    s = s2;
                    fun1();
                },
                "mouseup mouseout": function () {
                    s = s1;
                    fun1();
                },
                "click":function () {

                }
            });
        })();
        //init theme
        (function () {
            var c = st.head.theme[0];
            var o = c.getContext("2d");
            c.width = 30;
            c.height = 30;
            var s1 = bg.head_btn, s2 = bg.head_btn_md;
            var s = s1;
            o.lineWidth = 1;
            fun1();
            o.stroke();

            function fun1() {
                o.strokeStyle = s;
                o.fillStyle = s;
                o.stroke();
                o.clearRect(0, 0, 30, 30);
                o.beginPath();
                o.moveTo(10, 14);
                o.lineTo(10, 21);
                o.lineTo(20, 21);
                o.lineTo(20, 14);
                o.lineTo(23, 12);
                o.lineTo(20, 9);
                o.lineTo(10, 9);
                o.lineTo(7, 12);
                o.closePath();
            }

            st.head.theme.bind
            ({
                "mousedown": function () {
                    s = s2;
                    fun1();
                    o.fill();
                },
                "mouseup mouseout": function () {
                    s = s1;
                    fun1();
                    o.stroke();
                }
            });
        })();
        //home
        (function () {
            var c = st.head.home[0];
            var o = c.getContext("2d");
            c.width = 30;
            c.height = 30;
            var s1 = bg.head_btn, s2 = bg.head_btn_md;
            var s = s1;
            o.lineWidth = 1;
            fun1();
            o.stroke();

            function fun1() {
                o.strokeStyle = s;
                o.fillStyle = s;
                o.stroke();
                o.clearRect(0, 0, 30, 30);
                o.beginPath();
                o.moveTo(10, 14);
                o.lineTo(10, 21);
                o.lineTo(20, 21);
                o.lineTo(20, 14);
                o.lineTo(23, 14);
                o.lineTo(15, 8);
                o.lineTo(7, 14 );
                o.closePath();
            }

            st.head.home.bind
            ({
                "mousedown": function () {
                    s = s2;
                    fun1();
                    o.fill();
                },
                "mouseup mouseout": function () {
                    s = s1;
                    fun1();
                    o.stroke();
                }
            });
        })();
    }();
    //init cont
    (function () {
        var s1 = "w100%;h100%;poa;t0;tr300;";
        var play = st.cont.play.mst(s1 + "bg#454545;l-100%;por;ofh");
        var view = st.cont.view.mst(s1 + "bg#fff;l0");
        cont.append(view, play);
        //init play
        (function(){
            var bg=tag.canvas().mst("w100%;h100%");
            st.cont.play.bg=bg;
            st.cont.play.lrc=tag.div("lh30;fz16;c#fff;tac;mt200;por;tr600")
                .css({"letter-spacing":"1px",
                "text-shadow":"1px 1px 1px #000"});
            var box=tag.div().mst("h440;ofh;poa;t60;w100%")
                .append(tag.div("w100%;h100%;por")
                    .append(st.cont.play.lrc));
            play.append(bg,box,tag.div("w100%;h1;bg#aaa;poa;t290"));
            bg.attr({
                "width":bg.width(),
                "height":bg.height()
            })
        })();
        //init view
        (function () {
            var left = tag.div().mst("fl;fz14;w219;h100%;por;bgc#f5f5f5").css("border-right", "1px solid #ccc");
            var right = tag.div().mst("fl;fz14;w780;h100%;por")
                .css("overflow-y","auto");
            view.append(left, right);
            //init left
            void function () {
                var room = tag.div().mst("w100%;poa;t0;l0");
                //init room,room is left content
                void function () {
                    var nav=tag.div().mst("bgrgba(0,0,0,0.1);w100%;h30;lh30;fz14");
                    var name=tag.span().html("歌单列表").mst("ml10;c#666;fl;ls1");
                    var add=tag.canvas().mst("fr;w30;h30;cup").attr("title","新增歌单");
                    // init add
                    void function () {
                        var o=initCanvas(add)[1];
                        o.beginPath();
                        o.lineWidth=2;
                        o.strokeStyle="#666";
                        o.moveTo(10,15);
                        o.lineTo(20,15);
                        o.moveTo(15,10);
                        o.lineTo(15,20);
                        o.stroke();
                    }();
                    nav.append(name,add);
                    room.append(nav);
                }();
                var html="&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;默认列表";
                var undefined=tag.div("w100%;h30;bg#ccc;lh30;cup;ofh")
                    .html(html)
                    .click(function () {
                    this.x=!this.x;
                    if(this.x){
                        $(this).mst("hauto").css("overflow","visible");
                    }else {
                        $(this).mst("ofh");
                    }
                });
                //信息获取回调
                window.getList=function (e) {
                    e=e.songinfo;
                    undefined.append(tag.div("h30;lh30;w100%;ofh")
                        .css("border-bottom","1px solid #ccc")
                        .attr("data-id",e.song_id)
                        .click(function () {
                            media.tag.updateSong($(this).attr("data-id"))
                        })
                        .html(
                            "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"+e.title))
                };
                //信息获取
                for(var i=0;i<media.id_list.length;i++){
                    audio_play(media.id_list[i],"getList");
                }
                //获取完成
                room.append(undefined);
                var h1 = new House(room, left);
                h1.fix();
            }();

            // init right
            void function () {
                var room= tag.div().mst("w100%");
                right.append(room);
                function homepage() {
                    room.html("");
                    var banner=tag.div("w100%;h340;bg#ccc;ofh;por").css("border-bottom","1px solid #ccc");
                    (function () {
                        var arr=[
                            "data/app/music/images/banner1.jpg",
                            "data/app/music/images/banner2.jpg",
                            "data/app/music/images/banner3.jpg"
                        ];
                        var title=new Array(arr.length);
                        title[0]="薛之谦";
                        title[1]="李玉刚";
                        title[2]="陈一发儿";
                        //图片容器
                        for(var i=0;i<arr.length;i++){
                            arr[i]=tag.div("tr300;op0;poa;t0;l0;w100%;h100%;bgiurl('"+arr[i]+"');bgs100% auto");
                            banner.append(arr[i]);
                        }
                        //标题容器
                        var tBox=tag.div("bgrgba(0,0,0,0.6);w100%;h30;lh30;poa;b0");
                        banner.append(tBox);
                        for(var j=0;j<title.length;j++){
                            title[j]=tag.span().mst("tac;c#fff;tr300;w"+100/title.length+"%;h30").html(title[j]).attr("data-id",j);
                            tBox.append(title[j].click(function () {
                                showPic($(this).attr("data-id"))
                            }));
                        }
                        //轮播
                        var x=0;
                        function showPic(t) {
                            if(typeof t!=="undefined"){
                                x=t;
                            }
                            for(var i=0;i<arr.length;i++){
                                arr[i].mst("op0");
                                title[i].mst("bgnone;c#fff");
                            }
                            arr[x].mst("op1");
                            title[x].mst("bgrgba(255,255,255,0.6);c#000");
                            x++;
                            x>=arr.length&&(x=0);
                        }showPic();
                        setInterval(showPic,4000);

                    })();
                    room.append(banner);
                    //标题
                    room.append(tag.div("fz20;c#000;lh40;ml40;mt40")
                        .css({"border-bottom":"1px solid #aaa",
                        "letter-spacing":"4px"})
                        .html("站内音乐")
                    );
                    //站内音乐
                    //图片地址获取回调
                    window.setContPic=function (e) {
                        //e.songinfo.pic_small
                        $("#pic"+e.songinfo.song_id).attr({"src":e.songinfo.pic_radio});
                        $("#info"+e.songinfo.song_id).html(e.songinfo.title+"<br>"+e.songinfo.author);
                    };
                    //生成图片容器标签
                    for(var i=0;i<media.id_list.length;i++){
                        var  li=tag.span().mst("w200;h200;tac;ml42;mt40;por;cup;ofh")
                            .css("box-shadow","3px 3px 3px #000")
                            .attr("data-id",media.id_list[i]);
                        var can=tag.canvas().mst("w300;h300;bgrgba(0,0,0,0.6);op0").attr({"width":"200","height":"200",
                        "id":"can"+media.id_list[i]})
                            .mst("poa;t0;tr300;l-50;t-50");
                        var info=tag.div("ml6;w300%;poa;b0;c#fff;tr300;b-40")
                            .css({
                                "text-align":"left",
                                "text-shadow":"2px 2px 1px #000"
                            })
                            .attr("id","info"+media.id_list[i]);
                        //绘制
                        (function () {
                            var o=can[0].getContext("2d");
                            o.beginPath();
                            o.fillStyle="#fff";
                            o.strokeStyle="#fff";
                            o.lineWidth=1.5;
                            o.arc(100,80,24,0,Math.PI*2);
                            o.stroke();
                            o.beginPath();
                            o.moveTo(93,68);
                            o.lineTo(112,80);
                            o.lineTo(93,92);
                            o.fill();
                        })();
                                               li.append($("<img src='' id='pic"+media.id_list[i]+"'>")
                            .mst("w200;h200;bg#eee;poa;t0;l0"),can,info);
                        room.append(li);
                        li.hover
                        (
                            function () {
                                var id=$(this).attr("data-id");
                                $("#can"+id).mst("op1;w200;h200;l0;t0");
                                $("#info"+id).mst("b0");
                            },
                            function () {
                                var id=$(this).attr("data-id");
                                $("#can"+id).mst("op0;w300;h300;l-50;t-50");
                                $("#info"+id).mst("b-40");
                            }
                        ).click(function () {
                            media.tag.updateSong($(this).attr("data-id"))
                        });
                        audio_play(media.id_list[i],"setContPic");
                    }
                    room.append(tag.div("w100%;h50;pt10;bg#666;mt40;tac;fz14;c#fff")
                        .html("@qq1083631190<br>@重庆工程学院--第二课堂"));



                }
                //初始化主页
                homepage();
                //点击搜索方法
                window.musicSearchCallback=function (e) {
                    headChangeToLib();
                    e=e.song;
                    for(var i=0;i<e.length;i++){
                        room.append("歌名："+e[i].songname);
                        room.append("<br>艺人："+e[i].artistname);
                        room.append(tag.input("button","播放")
                            .attr("id",e[i].songid).click(function () {
                            //get_lrc(this.id,"musicGetLrc");
                            //audio_play(this.id,"musicGetSrc");
                            media.tag.updateSong(this.id);
                        }));
                        room.append("<hr>");
                    }
                };
                function search() {
                    var str=st.head.searchIpt.val();
                    if(str.trim()===""){
                        return;
                    }
                    room.html("");
                    query(str,"musicSearchCallback");

                }
                //实例化
                st.head.searchBtn.click(search);



                st.head.searchIpt.bind("keydown",function (e) {
                    if(e.which===13){
                        search();
                    }
                });
                //实例化home
                st.head.home.click(homepage);


            }();
        })();
    })();
    //init ctrl
    (function () {
        var past,play,next,icon,progress,part_line,volume,volume_bar,list;
        //init past
        (function () {
            past=tag.canvas().mst("fl;w34;h34;mt7;bd1px solid #fff;bdr20;ml30;cup");
            ctrl.append(past);
            st.ctrl.past=past;
            var arr=initCanvas(past);
            var o=arr[1];
            o.beginPath();
            o.moveTo(12,17);
            o.lineTo(12,10);
            o.lineTo(10,10);
            o.lineTo(10,24);
            o.lineTo(12,24);
            o.lineTo(12,17);
            o.lineTo(22,24);
            o.lineTo(22,10);
            o.closePath();
            o.fill();
        })();
        //init play
        (function ()
        {
            play=tag.canvas().mst("fl;w36;h36;mt5;bdr20;ml20;cup;bd1px solid #fff");
            ctrl.append(play);
            st.ctrl.play=play;
            var temp=initCanvas(play);
            var c=temp[0];
            var o=temp[1];
            var flag=20;
            st.ctrl.play.toplay=function () {
                flag+=2;
                if(flag<=20){
                    requestAnimationFrame(st.ctrl.play.toplay);
                    animate(flag);
                }
            };
            st.ctrl.play.tostop=function () {
                flag-=2;
                if(flag>=0){
                    requestAnimationFrame(st.ctrl.play.tostop);
                    animate(flag);
                }
            };
            function animate(f)
            {
                //二次曲线
                var t=(f/20)*(f/20)*20;
                //36*36
                var t1=(20-t)/20;//+2
                var t2=(20-t)/10;//+2
                var t8=(20-t)/2.5;//+8
                o.clearRect(0,0,c.width,c.height);
                o.beginPath();
                o.moveTo(12+t1/2,10-t1);
                o.lineTo(16+t2,10+t2+t1/2);
                o.lineTo(16+t2,26-t2-t1/2);
                o.lineTo(12+t1/2,26+t1);

                o.moveTo(20-t2,10+t2+t1/2);//x-2,y+3
                o.lineTo(24+t2,10+t8);//20>>0==24,10>>26,18
                o.lineTo(24+t2,26-t8);
                o.lineTo(20-t2,26-t2-t1/2);
                o.closePath();
                o.fill();
            }
            st.ctrl.play.tostop();

        })();
        //init next
        (function () {
            next=tag.canvas().mst("fl;w34;h34;mt7;bd1px solid #fff;bdr20;ml20;cup");
            ctrl.append(next);
            st.ctrl.next=next;
            var arr=initCanvas(next);
            var o=arr[1];
            o.beginPath();
            o.moveTo(22,17);
            o.lineTo(22,10);
            o.lineTo(24,10);
            o.lineTo(24,24);
            o.lineTo(22,24);
            o.lineTo(22,17);
            o.lineTo(12,24);
            o.lineTo(12,10);
            o.closePath();
            o.fill();
        })();
        //init icon
        (function ()
        {
            icon=tag.span().mst("fl;w34;h34;mt8;mr4;bgc#fff;bgiurl('images/music/user/0.jpg');bgs100% 100%;ml40;cup")
                .click(headChangeToPlay);
            ctrl.append(icon);
            st.ctrl.icon=icon;
        })();
        //init progress
        (function ()
        {
            progress=tag.div().mst("w500;h34;mt8;fl;por");
            ctrl.append(progress);
            var bar=tag.canvas().mst("poa;b0;w100%;h18;l0");
            var name=tag.span().mst("poa;t0;l0;w100;h16;lh16;fz16;ofh").html("");
            st.ctrl.songName=name;
            var lrc=tag.span().mst("poa;t0;l100;h16;lh16;fz16;ofh;w300;tac").html("");
            st.ctrl.lrc=lrc;
            var time_now=tag.span().html("00:00");
            var time_all=tag.span().html("00:00");
            var time=tag.span().mst("poa;t0;l400;h16;fz16;lh16;ofh;w100;tar").append(time_now,"/",time_all);
            progress.append(bar,name,lrc,time);
            //draw bar
            void function ()
            {
                var temp=initCanvas(bar);
                var c=temp[0];
                var o=temp[1];
                var w=c.width;
                var h=c.height;
                o.beginPath();
                o.fillStyle="rgba(0,0,0,0.3)";
                o.fillRect(0,h-3,w,2);
                //歌曲更新方法
                function updateSong(id) {
                    media.lrcText=undefined;
                    window.musicGetLrc=function (e) {
                        media.lrcText=e.lrcContent;
                        dealLrc();
                    };
                    window.musicGetSrc=function (e) {
                        try {
                            media.tag.src=e.bitrate.file_link;
                            updateInfo();
                            media.tag.toplay();
                            st.ctrl.songName.html(e.songinfo.title);
                            st.ctrl.icon.mst("bgiurl('"+e.songinfo.pic_small+"')");
                        }catch (e){
                            updateInfo();
                        }
                    };
                    window.getPic=function (e) {
                        st.ctrl.songName.html(e.songinfo.title);
                        st.ctrl.icon.mst("bgiurl('"+e.songinfo.pic_small+"')");
                    };
                    function dealLrc() {
                        (function () {
                            var lrcArr=media.lrcText;
                            var temp=[];

                            if(typeof media.lrcText==="undefined"){
                                st.cont.play.lrc.html("");
                            }

                            //log(t);
                            try {
                                lrcArr=lrcArr.replace(/\[/g,"");
                            }catch(e) {
                                //st.cont.play.lrc.html("");
                                return;
                            }
                            //log(t);

                            lrcArr=lrcArr.split("\n");
                            //log(t);

                            for(var i=0;i<lrcArr.length;i++){
                                lrcArr[i]=lrcArr[i].split("]");
                                //删除非时间类型的
                                if(isNaN(Number(lrcArr[i][0].substr(0,2)))){
                                    lrcArr.splice(i,1);
                                    i--;
                                    continue;
                                }
                                //数组拆分充重组
                                for(var j=0;j<lrcArr[i].length-1;j++){
                                    temp.push([lrcArr[i][j],lrcArr[i][lrcArr[i].length-1]]);
                                }
                            }
                            lrcArr=temp;
                            //时间格式化
                            for(var k=0;k<lrcArr.length;k++){
                                lrcArr[k][0]=lrcArr[k][0].split(":");
                                lrcArr[k][0]=lrcArr[k][0][0]*60+Number(lrcArr[k][0][1]);
                                lrcArr[k][0]=Number(lrcArr[k][0].toFixed(2));
                            }
                            //冒泡排序
                            (function () {
                                for(var i=0;i<lrcArr.length;i++){
                                    for(var j=i+1;j<lrcArr.length-1;j++){
                                        if(lrcArr[j][0]<lrcArr[i][0]){
                                            //换位置
                                            var temp=lrcArr[i];
                                            lrcArr[i]=lrcArr[j];
                                            lrcArr[j]=temp;
                                        }
                                    }
                                }

                            })();
                            st.cont.play.lrc.html("");//歌词
                            for(var x=0;x<lrcArr.length;x++){
                                st.cont.play.lrc.append(lrcArr[x][1]+"<br>");
                            }
                            media.lrcText=lrcArr;
                        })();
                    }
                    function updateInfo() {
                        //更新时间
                        //sec==>min:sec
                        function secToMin(num)
                        {
                            //取整
                            num=Math.round(num);
                            //填0
                            function fill0(n)
                            {
                                if(n<10)
                                {
                                    return "0"+n;
                                }
                                return n;
                            }
                            //返值
                            num=fill0(Math.floor(num/60))+":"+fill0(num%60);
                            return num;
                        }
                        //获取时长 获取失败则递归获取 直到成功
                        var time_all_temp=NaN;
                        function getTimeAll()
                        {
                            time_all_temp=media.tag.duration;
                            //获取失败
                            if(isNaN(time_all_temp))
                            {
                                setTimeout(function ()
                                {
                                    getTimeAll();
                                },100)
                            }
                            //获取成功
                            else
                            {
                                //输出总时长
                                time_all.html(secToMin(time_all_temp));
                            }

                        }getTimeAll();
                        //歌词整理
                        dealLrc();
                        $(media.tag).bind("timeupdate",function ()
                        {
                            var current=media.tag.currentTime;
                            time_now.html(secToMin(current));
                            o.clearRect(0,0,w,h);
                            o.fillStyle="rgba(0,0,0,0.3)";
                            o.fillRect(0,h-3,w,2);
                            o.fillStyle="#fff";
                            o.fillRect(0,h-3,current/time_all_temp*w,2);

                            //歌词
                            if(typeof media.lrcText==="undefined"){
                                lrc.html("");
                                return;
                            }
                            for(var i=0;i<media.lrcText.length;i++){
                                if(current<media.lrcText[i][0]){
                                    if(i===0){
                                        break;
                                    }
                                    lrc.html(media.lrcText[i-1][1]);
                                    st.cont.play.lrc.mst("t-"+(i-1)*30);
                                    break;
                                }
                            }
                            //play界面歌词 动起来~


                        });

                        //状态恢复
                        if(media.playing){
                            setTimeout(function () {
                                media.tag.play();
                                st.ctrl.play.toplay();
                            },100)
                        }else {
                            setTimeout(function(){
                                media.tag.pause();
                                st.ctrl.play.tostop();
                            },100);
                        }
                        //媒体信息更新
                        //st.ctrl.songName.html(media.id_list[media.id]);
                    }
                    //更新源文件
                    if (typeof id !== "undefined") {
                        updateInfo();
                        get_lrc(id, "musicGetLrc");
                        audio_play(id,"getPic");
                        audio_play(id,"musicGetSrc");
                    }
                }
                media.tag.updateSong=updateSong;
                media.tag.updateSong(media.id_list[media.id]);
                //进度点击事件
                $(c).click(function (e) {
                    media.tag.currentTime=
                        (e.pageX-$(this).offset().left)*media.tag.duration/500
                });
            }();
        })();
        //分割线
        part_line=tag.span().mst("fl;w1;h24;m13;bgcrgba(255,255,255,0.4)");
        ctrl.append(part_line);
        //init volume
        void function () {
            volume=tag.canvas().mst("fl;w30;h20;mt15;cup");
            ctrl.append(volume);
            var temp=initCanvas(volume);
            var c=temp[0];
            var o=temp[1];
            o.lineWidth=1.5;
            o.beginPath();
            o.moveTo(14,2);
            o.lineTo(14,18);
            o.lineTo(8,13);
            o.lineTo(5,13);
            o.lineTo(5,7);
            o.lineTo(8,7);
            o.closePath();
            o.stroke();
            x();
            function x() {
                o.clearRect(14,0,16,c.height);
                o.beginPath();
                //15,5        25,5
                //15,15       25,15
                o.arc(13,10,5,-Math.PI/4,Math.PI/4);
                o.stroke();
                o.beginPath();
                o.arc(13,10,8,-Math.PI/4,Math.PI/4);
                o.stroke();
                o.beginPath();
                o.arc(13,10,11,-Math.PI/4,Math.PI/4);
                o.stroke();
            }
        }();
        //init volumeBar
        void function () {
            volume_bar=tag.canvas().mst("fl;w100;h20;mt15;cup");
            ctrl.append(volume_bar);
            var temp=initCanvas(volume_bar);
            var o=temp[1];
            function fill(volume) {
                o.clearRect(0,0,100,20);
                o.fillStyle="rgba(0,0,0,0.5)";
                o.fillRect(0,9,100,2);
                o.fillStyle="#fff";
                o.fillRect(0,9,volume*100,2);
            }
            fill(media.tag.volume);
            volume_bar.click(function (e) {
                media.tag.volume=(e.pageX-$(this).offset().left)/100;
                fill(media.tag.volume)
            });
        }();
        //init song list
        void function () {
            list=tag.canvas().mst("w60;h20;mt15;ml20;cup");
            var box=tag.div().mst("w300;h550;bg"+bg.ctrl+";poa;b50;r-300;tr300");
            ctrl.append(list,box);
            list.bind("click",show);
            function show() {
                this.x=!this.x;
                if(this.x){
                    box.mst("r0");
                }else {
                    box.mst("r-300");
                }
            }
            //init box
            void function () {
                var bar;
                bar=tag.div().mst("w100%;h30;bgrgba(255,255,255,0.2)");
                box.append(bar);
                bar.append(
                    tag.input("button","列表循环")
                        .mst("h30;bgnone;c#fff;bdnone;w100")
                        .click(function () {
                        this.x=this.x||0;
                        this.x++;
                        this.x>=3&&(this.x=0);
                        switch (this.x){
                            case 0:$(this).val("列表循环");break;
                            case 1:$(this).val("单曲循环");break;
                            case 2:$(this).val("随机波翻");break;
                        }
                        media.loopType=this.x;
                    })
                );
                //内容
                var listBox=tag.div("w100%");
                box.append(listBox);
                window.getSongNameForList=function (e) {
                    var li=tag.div("w100%;h30;lh30;pl30;ofh")
                        .html(e.songinfo.title)
                        .attr("data-id",e.songinfo.song_id)
                        .hover(function () {
                            $(this).mst("bg#444")
                        },function () {
                            $(this).mst("bgnone")
                        })
                        .click(function () {
                            media.tag.updateSong($(this).attr("data-id"))
                        });
                    listBox.append(li)
                };
                window.initList=function () {
                    listBox.html("");
                    for(var i=0;i<media.id_list.length;i++){
                        audio_play(media.id_list[i],"getSongNameForList");
                    }
                };initList();
            }();
            //draw list
            void function () {
                var temp=initCanvas(list);
                var o=temp[1];
                o.lineWidth=1.5;
                o.beginPath();
                o.moveTo(0,2);
                o.lineTo(8,2);
                o.moveTo(0,10);
                o.lineTo(8,10);
                o.moveTo(0,18);
                o.lineTo(19,18);
                o.moveTo(11,3);
                o.lineTo(18,8);
                o.lineTo(11,13);
                o.closePath();
                o.stroke();
                o.font="16px Arial";
                o.fillText(media.id_list.length+"",21,18);
            }();
        }();
    })();

    function initCanvas($canvas) {
        var c=$canvas[0];
        c.width=$canvas.width();
        c.height=$canvas.height();
        var o=c.getContext("2d");
        o.strokeStyle="#fff";
        o.fillStyle="#fff";
        return [c,o];
    }
    //播放、暂停、上一曲、下一曲 事件绑定
    (function () {
        st.ctrl.past.click(function () {
            media.id--;
            media.id<0&&(media.id=media.id_list.length-1);
            media.tag.updateSong(media.id_list[media.id]);
        });
        window.playClick=function () {
            media.playing=!media.playing;
            if(media.playing){
                media.tag.play();
                st.ctrl.play.toplay();
            }else {
                media.tag.pause();
                st.ctrl.play.tostop();
            }
        };
        st.ctrl.play.click(playClick);
        st.ctrl.next.click(function () {
                media.id++;
                media.id>=media.id_list.length&&(media.id=0);
                media.tag.updateSong(media.id_list[media.id]);
        })
    })();
    //动画绘制

}();